<#import "function.ftl" as func>
<#assign package=model.variables.package>
<#assign class=model.variables.class>
<#assign classVar=model.variables.classVar>
<#assign comment=model.tabComment>
<#assign subtables=model.subTableList>
<#assign pk=func.getPk(model) >
<#assign pkModel=model.pkModel >
<#assign pkVar=func.convertUnderLine(pk) >
<#assign pkType=func.getPkType(model)>
<#assign fkType=func.getFkType(model)>
<#assign system=vars.system>
<#assign domain=vars.domain>
<#assign apiProject=vars.apiProject>
<#assign tableName=model.tableName>
<#assign colList=model.columnList>
<#assign commonList=model.commonList>
<template>
  <rx-layout style="padding: 10px">
    <template #middle>
      <rx-fit v-model="fitSearch">
        <template #head>
            <div style="display: flex;align-items: center;justify-content: space-between;">
              <div class="table-operator" >
                <a-button  type="primary" @click="add">
                  <PlusOutlined />
                  {{$ti18('rxList.newBtn','新建')}}
                </a-button>
                <a-dropdown v-if="editEnable && selectedRowKeys.length > 0 || removeEnable && selectedRowKeys.length > 0">
                  <a-button style="margin-left: 8px">
                    {{$ti18('rxList.moreBtn','更多')}}
                    <DownOutlined />
                  </a-button>
                  <template #overlay>
                    <a-menu>
                      <a-menu-item key="1" v-if="editEnable && selectedRowKeys.length > 0" @click="editOne">
                        <EditOutlined />
                        {{$ti18('rxList.editBtn','编辑')}}
                      </a-menu-item>
                      <a-menu-item key="2" v-if="removeEnable && selectedRowKeys.length > 0" @click="delByIds(selectedRowKeys)">
                        <DeleteOutlined />
                        {{$ti18('rxList.delBtn','删除')}}
                      </a-menu-item>
                    </a-menu>
                  </template>
                </a-dropdown>
              </div>
              <span class="search-btn" @click.stop="searchshow" @mousedown.stop><SearchOutlined/>{{ $ti18('rxList.leachBtn', '过滤') }}</span>
            </div>
        </template>
        <template #search>
          <a-form :layout="colLayout">
            <a-row :gutter="20">
                <#list commonList as col>
                    <#assign colName=func.convertUnderLine(col.columnName)>
                    <#if func.isExcludeField(colName) >
              <a-col :span="colSpan">
                <a-form-item label="${col.comment}">
                          <#assign isNotNull=col.getIsNotNull()?string("true","false") >
                          <#if (col.colType=="java.util.Date")>
                     从<a-date-picker placeholder="请输入${col.comment}" v-model:value="urlConfig.queryParam.Q_${col.columnName}_D_GT"
                                           format="YYYY-MM-DD"/>
                     至<a-date-picker placeholder="请输入${col.comment}" v-model:value="urlConfig.queryParam.Q_${col.columnName}_D_LT"
                                           format="YYYY-MM-DD"/>
                          <#elseif (col.colType=="Integer")>
                     <a-input-number :min="0" :max="1000000" placeholder="请输入${col.comment}"
                                            v-model:value="urlConfig.queryParam.Q_${col.columnName}_I_EQ"/>
                          <#else>
                     <a-input placeholder="请输入${col.comment}" v-model:value="urlConfig.queryParam.Q_${col.columnName}_S_LK"/>
                          </#if>
                </a-form-item>
              </a-col>
                    </#if>
                </#list>
            </a-row>
          </a-form>
          <div class="list-search-toolbar">
            <a-button type="primary" @click="search">
              <SearchOutlined/>
              {{ $ti18('rxList.searchBtn', '查询') }}
            </a-button>
            <a-button style="margin-left: 4px" @click="resetSearch">
              <RedoOutlined />
              {{ $ti18('rxList.resetBtn', '重置') }}
            </a-button>
          </div>
        </template>
        <template #middle>
          <rx-grid
              ref="table"
              :hasPage="true"
              :urlConfig="urlConfig"
              :selectConfig="selectConfig"
              :pageConfig="pageConfig"
              url="/${apiProject}/${system}/${package}/${classVar}/query"
              field="${pkVar}"
              :columns="columns"
              @selectMethod="onSelectMethod"
          >
            <template #action="{ row, rowIndex }">
              <RxGridAction :size="2">
                <div v-if="editEnable" @click.stop="edit(row)">
                  {{$ti18('rxList.editBtn','编辑')}}
                </div>
                <div v-if="removeEnable" @click.stop="delByIds([row.${pkVar}])">
                  {{$ti18('rxList.delBtn','删除')}}
                </div>
              </RxGridAction>
            </template>
          </rx-grid>
        </template>
      </rx-fit>
    </template>
  </rx-layout>
</template>

<script>
  import ${class}Api from '@/common/api/${system}/${package}/${classVar}'
  import ${class}Edit from './${class}Edit.vue'
  import {BaseList,RxFit } from 'jpaas-base-lib';
  export default {
    name: '${class}List',
    mixins: [BaseList],
    components: {
      RxFit
    },
    data() {
      return {
        urlConfig: {
          ajaxType: 'post',
          contentType: 'json',
          queryParam: {},
          dataField: 'result.data',
          totalField: 'result.totalCount'
        },
        selectConfig: {
          type: 'checkbox'
        },
        pageConfig: {
          pageSize: 10,
          pageSizes: [10, 30, 40]
        },
        columns: [
          <#list commonList as col>
          <#assign colName=func.convertUnderLine(col.columnName)>
          <#if func.isExcludeField( colName) >
          {title: '${col.comment}', field: '${colName}', minWidth: 100},
          </#if>
          </#list>
          {title: '操作', minWidth: 100, field: 'action', slots: {default: 'action'}}
        ],
        component:${class}Edit,
        comment:"${comment}",
        widthHeight:['800px','600px'],
      }
    },
    methods:{
      delById(ids){
        return ${class}Api.del({ ids: ids.join(',') });
      }
    }
  }
</script>
<style scoped>
  .table-operator {
    padding:4px;
  }
  .table-operator button {
    margin:2px;
  }
</style>

